package source.view.viewobjects;

import java.awt.Color;
import java.awt.Graphics2D;
import java.util.Hashtable;

import source.events.action.MoveDirection;
import source.model.ObjectID;
import source.model.type.UnitType;
import source.view.ImageLibrary;

public class ViewUnit extends ViewObjectWithStats {
	private UnitType uType;
	private MoveDirection direction;
	
	public ViewUnit(UnitType uType, ObjectID id, int playerID, Hashtable<String, String> stats){
		super(id, playerID, stats);
		this.uType = uType;
		this.direction = MoveDirection.N;
	}
	
	public void setOrientation(MoveDirection dir){
		this.direction = dir;
	}
	
	public UnitType getUtype(){
		return uType;
	}

	public void paint(Graphics2D g) {
		Graphics2D g2 = (Graphics2D) g.create();
		g2.translate(10, -25);
		g2.scale(.6,.6);
		g2.drawImage(ImageLibrary.getUnitImage(uType, direction), null, 0,0);
		g2.dispose();
		
		// This is code to draw strings and stuff about the unit.
		g2 = (Graphics2D) g.create();
		g2.setColor(Color.YELLOW);
		g2.drawString(getPlayerID(), 0, 0);
		g2.drawString(uType.toString(), 0, 13);
		g2.dispose();
		
	}
}
